<template>
  <li class="todo-item" :class="{ done: todoItem.completed }">
    <label>
      <input
        type="checkbox"
        :checked="todoItem.completed"
        @click="$emit('changeState', $event)"
      />
      {{ todoItem.content }}
      <span class="chek-button"></span>
    </label>
    <span class="del-button" @click="$emit('delTodo')"></span>
  </li>
</template>

<script>
export default {
  name: 'TodoListItem',
  props: ['todoItem'],
};
</script>

<style>
/* todo-item */
.todo-item {
  position: relative;
  padding: 16px;
  color: #626262;
  background-color: white;
  border-radius: 8px;
}
.todo-item label {
  position: relative;
  display: flex;
  align-items: center;
}
.todo-item.done label {
  text-decoration: line-through;
  font-style: italic;
  color: #7d7b7b;
}
.todo-item label span.chek-button {
  position: absolute;
  top: 0;
}
.todo-item label span.chek-button::before,
.todo-item label span.chek-button::after {
  content: "";
  display: block;
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
}
.todo-item label span.chek-button::before {
  border: 1px solid #b382f9;
}
.todo-item label span.chek-button::after {
  transition: all 0.4s;
  transform: translate(1px, 1px) scale(0.8);
  background-color: #b382f9;
  opacity: 0;
}
.todo-item label input {
  margin-right: 16px;
  opacity: 0;
}
.todo-item label input:checked + span.chek-button::after {
  opacity: 1;
}
/* del-button */
.todo-item span.del-button {
  position: absolute;
  top: 0;
  right: 0;
  display: block;
  width: 16px;
  height: 100%;
  background: linear-gradient(#c0a5f3, #7f95f7);
  cursor: pointer;
}
</style>
